package com.cuckoo.cuckoo_app2.utils;

import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.content.ContextCompat;

/**
 * 权限检测工具
 */
public class PermissionChecker {

    /**
     * 检测工具
     * @param context
     * @param permission
     * @return
     */
    public static boolean hasPermission(Context context, String permission) {
        if (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
            return true;
        }
        return false;
    }

    // 示例：检查相机权限
    public static boolean hasCameraPermission(Context context) {
        return hasPermission(context, android.Manifest.permission.CAMERA);
    }

    // 示例：检查存储权限
    public static boolean hasStoragePermission(Context context) {
        return hasPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }

    // 示例：检测通知权限
    public static boolean hasNotificationPermission(Context context) {
        return hasPermission(context, android.Manifest.permission.POST_NOTIFICATIONS);
    }
}
